package com.headwire.kw.helpers;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.text.Normalizer;

public class AccentRemover {
	public static void removeAccents(String inFilePath, String outFilePath) throws IOException {
		// set up input file
		File inFile = new File(inFilePath);
		BufferedReader in = new BufferedReader(new FileReader(inFile));
		
		// set up output file
		File outFile = new File(outFilePath);
		FileOutputStream fos = new FileOutputStream(outFile);
		PrintWriter out = new PrintWriter(new OutputStreamWriter(fos,"UTF-8"));
		
		// begin parsing
		String cur;
		while((cur = in.readLine())!= null) {
			String s = Normalizer.normalize(cur,java.text.Normalizer.Form.NFKD).replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); 
			out.println(s);
		}
		in.close();
		out.close();
	}
}
